package com.dmt.view.filterBox
{
	import flash.events.Event;
	
	import mx.containers.HBox;
	import mx.controls.Alert;
	import mx.controls.DateField;
	import mx.controls.RadioButtonGroup;
	import mx.events.ItemClickEvent;

	public class FilterBox extends HBox
	{
		[Bindable]
		public var firstDate:String = new String;
		
		[Bindable]
		public var secondDate:String = new String;
		
		[Bindable]
		public var bothDates:String = new String;
		
		[Bindable]
		public var selectedGenre:String = new String;
		
		[Bindable]
		public var mainXml:XML = <filters>
									<clients>
										<client name="James Blomberg" />
										<client name="Lisa Minnot" />
									</clients>
									<technologies>
										<tech name="ASP"/>
										<tech name="CSS"/>
										<tech name="Fireworks"/>
										<tech name="Flash"/>
										<tech name="Flex"/>
										<tech name="HTML"/>
										<tech name="Java"/>
										<tech name="Javascript"/>
										<tech name="PHP"/>
										<tech name="Photoshop"/>
									</technologies>
									<teams>
										<team name="ECS" />
										<team name="New Media" />
										<team name="GE.com" />
									</teams>
									<apps>
										<app name="Sitebuilder"/>
										<app name="My Six Sigma"/>
										<app name="GE.com"/>
										<app name="Pipeline"/>
										<app name="PR Insight"/>
										<app name="Pen Application"/>
										<app name="GE Toolbar"/>
										<app name="SourcingInsight"/>
										<app name="CFSInsight"/>
										<app name="AMInsight"/>
									</apps>
								</filters>;
		
		public function FilterBox()
		{
			super();
		}
		
		// for dateFields
		protected function dateChanged(e:Event):void
		{
			var date:Date = DateField(e.target).selectedDate;
			if (date != null)
			{
				if(e.target.id == "fromDate")
				{
					firstDate = (date.getMonth()+1).toString() + '/' + date.getDate() + '/' + date.getFullYear().toString();
				}
				if(e.target.id == "toDate")
				{
					secondDate = (date.getMonth()+1).toString() + '/' + date.getDate() + '/' + date.getFullYear().toString();
				}
			}
			bothDates = firstDate + ' - ' + secondDate;
		}
		
		protected function onRadioBtn_click(e:ItemClickEvent):void
		{
			selectedGenre = RadioButtonGroup(e.target).selectedValue.toString();
		}
	}
}